package day;

public class P326 {
    public boolean isPowerOfThree(int n) {
        if (n == 0) {
            return false;
        } else if (n == 1) {
            return true;
        }
        int tmp = n;
        while (tmp % 3 == 0) {
            tmp /= 3;
        }
        return tmp == 1 ? true : false;
    }

    public static void main(String[] args) {
        boolean powerOfThree = new P326().isPowerOfThree(27);
        System.out.println(powerOfThree);
    }
}
